package com.zzy.chapter2.contorller;

import com.zzy.chapter2.pojo.AbstractProductItem;
import com.zzy.chapter2.pojo.ProductItem;
import com.zzy.chapter2.pojo.ProductItemComposite;
import com.zzy.chapter2.service.ProductItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductItemController {

    @Autowired
    private ProductItemService productItemService;

    @PostMapping("/fetchAll")
    public ProductItemComposite fetchAllProductItem() {
        return productItemService.fetchAllProductItem();
    }

    @PostMapping("/addItems")
    public ProductItemComposite addProductItem(@RequestBody ProductItem productItem) {
        return productItemService.addProductItem(productItem);
    }

    @PostMapping("/delItems")
    public ProductItemComposite delProductItem(@RequestBody ProductItem productItem) {
        return productItemService.delProductItem(productItem);
    }
}
